Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow identifiers to be defined with a block #110

Merged

Conversation

hugopeixoto
Copy link
Contributor

Now that ::association and ::field receive an optional block,
::identifier should receive it as well.

Since all three methods receive an optional block, the block extraction
mechanism was moved to AutoExtractor. Removing this mechanism from
each individual method made them very similar. ::association now uses
::field instead of directly adding the field to the current view.

Addresses #109


def self.inherited(subclass)
subclass.send(:view_collection).inherit(view_collection)
def self.identifier(method, name: method, extractor: AutoExtractor.new, &block)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

def self.inherited(subclass)
subclass.send(:view_collection).inherit(view_collection)
end
private_class_method :inherited
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

Now that `::association` and `::field` receive an optional block,
`::identifier` should receive it as well.

Since all three methods receive an optional block, the block extraction
mechanism was moved to `AutoExtractor`. Removing this mechanism from
each individual method made them very similar. `::association` now uses
`::field` instead of directly adding the field to the current view.
@hugopeixoto hugopeixoto force-pushed the feature/pass-a-block-to-identifier branch from fa9f3ff to 22b04ff Compare October 25, 2018 21:11
@hugopeixoto
Copy link
Contributor Author

I've added documentation. Feel free to suggest better examples, I used the one I needed on my project, but it may be a bit weird.

@philipqnguyen
Copy link
Contributor

LGTM!

@mcclayton
Copy link
Contributor

We’ll hopefully get this out soon in the next release of Blueprinter, thanks for this!

@mcclayton mcclayton merged commit 2b4c5d7 into procore-oss:master Oct 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants